import { Injectable, Injector } from '@angular/core';
import { Constant, ServiceResult } from '@core/constant';
import {_HttpClient, SettingsService} from '@delon/theme';
import { MyHttpClient } from '../MyHttpClient';

@Injectable()
export class noticeService {
  get cnt(): Constant {
    return this.injector.get(Constant);
  }

  constructor(
    private injector: Injector,
    private http: _HttpClient,
    private myHttp: MyHttpClient,
    public setting: SettingsService,

  ) {}

  /**
   * 分页获取商品
   */
  list(): string {
    return `${this.cnt.baseUrl}/rest/fxjNoticeController/list/`+this.setting.user.username;
  }
  /**
   * 分页获取商品
   */
  listdhcar(): string {
    return `${this.cnt.baseUrl}/rest/fxjNoticeController/list/`+this.setting.user.username;
  }
  listposdetail(): string {
    return `${this.cnt.baseUrl}/rest/posDetailController/list/`+this.setting.user.username;
  }
  list2(): string {
    return `${this.cnt.baseUrl}/api/sms/prod/product/page2`;
  }
  /**
   * 上传图片
   */
  // uploadUrl() {
  //   return `${this.cnt.baseUrl}/zuul/api/sms/prod/product/proImg`;
  // }

  uploadUrl() {
    return `${this.cnt.baseUrl}/rest/base/upload`;
  }
  
  delfile(productId) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/base/delfile/${productId}`,
    );
  }
  /**
   * 添加商品
   * @param prods
   */
  addPro(prods) {
    return this.http.post(
      `${this.cnt.baseUrl}/api/sms/prod/product/addPro`,
      prods,
    );
  }

  /**
   * 修改商品
   * @param product
   */
  // /rest/fxjdhData08Controller/{id}
  editPro(product) {
    return this.http.post(
      // `${this.cnt.baseUrl}/rest/fxjNoticeController/${product.id}`,
      `${this.cnt.baseUrl}/rest/fxjdhData08Controller`,
      product,
    );
  }
  editProA(product) {
    return this.http.put(
      `${this.cnt.baseUrl}/rest/fxjNoticeController/${product.id}`,
      // `${this.cnt.baseUrl}/rest/fxjdhData08Controller`,
      product,
    );
  }

  savemen(fxjOrderMainPage) {
    return this.http.post(
      `${this.cnt.baseUrl}/rest/fxjOrderMainController/savemen`+this.setting.user.username,
      fxjOrderMainPage,
    );
  }

  dhlist(): string {
    return `${this.cnt.baseUrl}/rest/fxjdhData08Controller/list/`+this.setting.user.username;
  }

  getProduct(productId) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjNoticeController/${productId}`,
    );
  }

  
  getCusInfo(productId){
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjOrderMainController/${productId}`,
    );
  }

  getProductFk(productId) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjLoanFkController/${productId}`,
    );
  }
  getProductPl(productId) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjPlReplanController/${productId}`,
    );
  }

  emenurl(): string {
    return `${this.cnt.baseUrl}/rest/fxjOrderMainController/emenlist/`;
  }


  batchUnder(ids) {
    return this.myHttp.post(
      `${this.cnt.baseUrl}/api/sms/prod/product/batchDown`,
      { ids: ids },
    );
  }

  batchSale(ids) {
    return this.myHttp.post(
      `${this.cnt.baseUrl}/api/sms/prod/product/batchUp`,
      { ids: ids },
    );
  }

  batchRepdate(): string {
    return `${this.cnt.baseUrl}/zuul/api/sms/prod/product/batchRepdate`;
  }

  getProductByIds(ids) {
    return this.myHttp.post(
      `${this.cnt.baseUrl}/api/sms/prod/product/getProducts`,
      { ids: ids },
    );
  }

  batchPrice(list) {
    return this.http.post(
      `${this.cnt.baseUrl}/api/sms/prod/product/batchPrice`,
      list,
    );
  }

  configUpload(): string {
    return `${this.cnt.baseUrl}/zuul/api/sms/prod/product/priceConfig`;
  }

  uploadcarinfo(): string {
    return `${this.cnt.baseUrl}/rest/fxjDhImpController/uploadexcel?username=`+this.setting.user.username;
  }

  doSync() {
    return this.http.post(`${this.cnt.baseUrl}/api/sms/prod/product/dosync`);
  }
}
